define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_modelAdd(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"id": "001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		};

		function get_data_modelDetail(result) {
			if(false) {
				result = '{"success":true,"msg":"","result":{"id":"001","name":"普通配送","company_id":"001","kind":"货到付款","status":false,"base_weight":1,"add_weight":1,"base_cose":"5.0","add_cose":"10.0","region_type":1,"appoint":[{"region":[{"region_id":"001"},{"region_id":"002"}],"base_cose":"5.0","add_cose":"10.0"},{"region":[{"region_id":"006"},{"region_id":"007"}],"base_cose":"15.0","add_cose":"20.0"}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}
		//返回信息
		return {
			//新增运费模板
			model_eidt: function(id, name, company_id,kind, status, after_balance,base_weight, add_weight, base_cos, add_cos, region_type, callback) {
				var updateParams = new Object();
				updateParams.id = id;
				updateParams.name = name;
				updateParams.company_id = company_id;
				updateParams.kind = kind;
				updateParams.status = status;
				updateParams.after_balance = after_balance;
				updateParams.base_weight = base_weight;
				updateParams.add_weight = add_weight;
				updateParams.base_cose = base_cos;
				updateParams.add_cose = add_cos;
				updateParams.region_type = region_type;
				updateParams = JSON.stringify(updateParams);
				
				//post请求
				Http.post({
					method: 'member.freightmode.edit',
					updateParams: updateParams
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_modelAdd(result).success);

				}, function(e) {

				}, function() {

				});
			},
			model_detail: function(id, callback) {
				Http.post({
					method: 'member.freightmode.detail',
					id: id
				}, function(result) {
					if(callback)
					callback(get_data_modelDetail(result).result);
				}, function(e) {

				}, function() {

				})
			},
			company_list:function(callback){
				Http.post({
					method:'member.logisticscomp.getlist',
					pagelimit:8,
					nPage:1,
					show_count:5
				},function(result){
					if(callback)
					callback(result.result);
				})
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Logistics_Edit", factory);
});